package com.ark.mapper;

import com.ark.entity.SetmealDish;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper extends BaseMapper<SetmealDish> {

    /**
     * 根据菜品id查询对应的套餐id
     * @param dishIds 菜品id
     * @return 套餐id
     */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);


    /**
     * 根据套餐id删除套餐菜品关系表中的数据
     * @param setmealIds 套餐id
     * @return 删除条数
     */
    Integer deleteBySetmealIds(List<Long> setmealIds);

    /**
     * 根据套餐id删除关联关系
     * @param setmealId 套餐id
     * @return 删除行数
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    Integer deleteBySetmealId(Long setmealId);

    /**
     * 根据套餐id查询套餐和菜品关系
     * @param setmealId 套餐id
     * @return 套餐菜品关系列表
     */
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> getBySetmealId(Long setmealId);
}
